<?php
//保存要修改的留言
$id=isset($_GET['id'])?$_GET['id']:0;//如果地址栏有ID参数，就取ID参数的值，否则为0
//获取用户输入的修改后的信息
$username=$_REQUEST['username'];
$message=$_REQUEST['message'];
$sex=$_REQUEST['sex'];
$imgurl=$_REQUEST['imgurl'];
require 'dbcon.php';
$sql="update t_message set username='{$username}',message='{$message}',sex='{$sex}',imgurl='{$imgurl}' where id={$id}";
$rs=$db->query($sql);
if ($rs==true)
{
    echo "<script language='javascript' type='text/javascript'>";
   // echo "alert('留言成功！');";
    echo "window.location.href='index.php'";
    echo "</script>";
} 
else
{
    echo "<script language='javascript' type='text/javascript'>";
    echo "alert('编辑失败！');";
    echo "history.back(-1);";//返回上一页
    echo "</script>";
}

